package com.example.springboot.service;


import com.example.springboot.mapper.EquipmentDao;
import com.example.springboot.pojo.Equipment;
import com.example.springboot.pojo.WorkOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("equipmentService")
public class EquipmentServiceImpl {
    @Autowired
    EquipmentDao equipmentDao;

    public boolean addEquipment(Equipment equipment) {
        if(equipmentDao.queryById(equipment.getId())!=null)
            return false;
        equipmentDao.addEquipment(equipment);
        return true;
    }


    public Equipment queryById(int id) {
        return equipmentDao.queryById(id);
    }


    public boolean deleteById(int id) {
        equipmentDao.deleteById(id);
        return true;
    }


    public List<Equipment> getEquipmentList() {
        return equipmentDao.getEquipmentList();
    }


    public boolean updateById(Equipment equipment) {
        Equipment equipment1 = equipmentDao.queryById(equipment.getId());
        if(equipment1==null)
            return false;
        equipmentDao.updateById(equipment);
        return true;
    }

    public boolean MultideleteById(List<Integer> list) {
        for(int i:list)
            equipmentDao.deleteById(i);
        return true;
    }


    public List<Equipment> getEquipmentListByCondition(Map<String, String> map) {
        List<Equipment> equipmentList = equipmentDao.getEquipmentListByCondition(map);
        return equipmentList;
    }


    public List<WorkOrder> getWorkOrderListById(int id) {
        List<WorkOrder> workOrderList = equipmentDao.getWorkOrderListById(id);
        return workOrderList;
    }

}
